/* LoadRowRender.java

{{IS_NOTE
	Purpose:

	Description:

	History:
		Oct 8, 2007 9:41:06 AM     2007, Created by Dennis.Chen
}}IS_NOTE

Copyright (C) 2007 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
	This program is distributed under GPL Version 2.0 in the hope that
	it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.imdm.portal.mdmer;

import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Label;
import org.zkoss.zul.Button;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.RowRendererExt;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;

/**
 * @author Firebear
 *
 */
public class MdmerRowRenderer implements RowRenderer,RowRendererExt {

	/* (non-Javadoc)
	 * @see org.zkoss.zul.RowRenderer#render(org.zkoss.zul.Row, java.lang.Object)
	 */
	public void render(Row row, Object data) throws Exception {
		row.getChildren().remove(0);

		java.util.Map.Entry<String, Mdmer> entry = (java.util.Map.Entry<String, Mdmer>)data;
		
		Mdmer mdmer = (Mdmer)entry.getValue();

		Label lbFirstName = new Label(mdmer.getFirstName());
		Label lbLastName = new Label(mdmer.getLastName());
		Label lbESN = new Label(mdmer.getESN());
		Label lbDept = new Label(mdmer.getDepartment());

		Button lbDelete = new Button("delete");
//		lbDelete.setAttribute("onClick","deleteMdmer(" + 
//				                        mdmer.getFirstName() + "," +
//										mdmer.getLastName());
//		lbDelete.addEventListener("onClick", this);

		lbDelete.setAttribute("onClick","System.out.println('hello worl');"); 
		
		row.appendChild(lbFirstName);
		row.appendChild(lbLastName);
		row.appendChild(lbESN);
		row.appendChild(lbDept);
		row.appendChild(lbDelete);
	}

	public int getControls() {
		return RowRendererExt.DETACH_ON_UNLOAD;
	}


	public Component newCell(Row row) {
		return new Label("...updating");
	}

	public Row newRow(Grid grid) {
		return new Row();
	}

}
